#include<bits/stdc++.h>
using namespace std;
const int N = 2e5+10,MOD = 1e9+7;
int n;
struct segment_tree1{
    int ls[N*160],rs[N*160];
    int sum[N*160];
    int pcnt;
    void update(int &now,int l,int r,int p,int v){
        if(!now){
            now = ++pcnt;
        }
        sum[now] = (sum[now] + v)%MOD;
        if(l == r){
            return;
        }
        int mid = (l + r)/2;
        if(p <= mid){
            update(ls[now],l,mid,p,v);
        }else{
            update(rs[now],mid+1,r,p,v);
        }
    }
    int qsum(int now,int l,int r,int x,int y){
        if(x <= l && r <= y){
            return sum[now];
        }
        int mid = (l + r)/2;
        int su = 0;
        if(x <= mid){
            su = (su + qsum(ls[now],l,mid,x,y))%MOD;
        }
        if(mid < y){
            su = (su + qsum(rs[now],mid+1,r,x,y))%MOD;
        }
        return su;
    }
}sg1;
struct BIT{
    int rots[N];
    inline int lowbit(int x){
        return x & (-x);
    }
    void update(int p,int x,int v){
        for(int i = p;i <= n;i += lowbit(i)){
            sg1.update(rots[i],1,n,x,v);
        }
    }
    int query(int p,int x,int y){
        int su = 0;
        for(int i = p;i;i -= lowbit(i)){
            su = (su + sg1.qsum(rots[i],1,n,x,y))%MOD;
        }
        return su;
    }
    int query(int l,int r,int x,int y){
        return (query(r,x,y) - query(l - 1,x,y) + MOD)%MOD;
    }
}bit1,bit2;
int a[N],val[N];
int main(){
    int m;
    cin>>n>>m;
    int bans = 0;
    for(int i = 1;i<=n;i++){
        cin>>a[i]>>val[i];
        bans = (bans + bit1.query(i,a[i],n))%MOD;
        bans = (bans + 1ll*val[i]*bit2.query(i,a[i],n)%MOD)%MOD;
        bit1.update(i,a[i],val[i]);
        bit2.update(i,a[i],1);
    }
    //cerr<<bans<<'\n';
    for(int i = 1;i<=m;i++){
        int x,y;
        cin>>x>>y;
        if(x > y)swap(x,y);
        bit1.update(x,a[x],MOD-val[x]);
        bit2.update(x,a[x],MOD-1);
        bit1.update(y,a[y],MOD-val[y]);
        bit2.update(y,a[y],MOD-1);
        if(a[x] > a[y]){
            bans = (1ll*bans + MOD - val[x] + MOD - val[y])%MOD;
        }
        bans = (bans + MOD - bit1.query(x,a[x],n))%MOD;
        bans = (bans + MOD - 1ll*bit2.query(x,a[x],n)*val[x]%MOD)%MOD;
        bans = (bans + MOD - bit1.query(x,n,1,a[x]))%MOD;
        bans = (bans + MOD - 1ll*bit2.query(x,n,1,a[x])*val[x]%MOD)%MOD;
        bans = (bans + MOD - bit1.query(y,a[y],n))%MOD;
        bans = (bans + MOD - 1ll*bit2.query(y,a[y],n)*val[y]%MOD)%MOD;
        bans = (bans + MOD - bit1.query(y,n,1,a[y]))%MOD;
        bans = (bans + MOD - 1ll*bit2.query(y,n,1,a[y])*val[y]%MOD)%MOD;

        swap(a[x],a[y]);
        swap(val[x],val[y]);

        bans = (bans + bit1.query(x,a[x],n))%MOD;
        bans = (bans + 1ll*bit2.query(x,a[x],n)*val[x]%MOD)%MOD;
        bans = (bans + bit1.query(x,n,1,a[x]))%MOD;
        bans = (bans + 1ll*bit2.query(x,n,1,a[x])*val[x]%MOD)%MOD;
        bans = (bans + bit1.query(y,a[y],n))%MOD;
        bans = (bans + 1ll*bit2.query(y,a[y],n)*val[y]%MOD)%MOD;
        bans = (bans + bit1.query(y,n,1,a[y]))%MOD;
        bans = (bans + 1ll*bit2.query(y,n,1,a[y])*val[y]%MOD)%MOD;
        if(a[x] > a[y]){
            bans = (1ll*bans + val[x] + val[y])%MOD;
        }
        bit1.update(x,a[x],val[x]);
        bit2.update(x,a[x],1);
        bit1.update(y,a[y],val[y]);
        bit2.update(y,a[y],1);
        cout<<bans<<'\n';
    }
}